package com.feedback.ui;

import android.app.ListActivity;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import com.feedback.a.a;
import com.feedback.a.b;
import com.feedback.a.c;
import com.feedback.a.d;
import com.feedback.a.e;
import com.feedback.b.a;
import com.feedback.b.c;
import com.mobclick.android.t;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class FeedbackConversation extends ListActivity
{
  static Context a = null;
  static final String c = FeedbackConversation.class.getSimpleName();
  static boolean d = true;
  public static ExecutorService executorService = Executors.newFixedThreadPool(3);
  boolean b = false;
  private d e;
  private c f;
  private TextView g;
  private EditText h;
  private Button i;
  private b j;

  private void a()
  {
    this.g.setText(getString(t.a(this, "string", "UMFeedbackConversationTitle")));
    this.i.setText(getString(t.a(this, "string", "UMFeedbackSummit")));
  }

  public static void setUserContext(Context paramContext)
  {
    a = paramContext;
  }

  public void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    requestWindowFeature(1);
    setContentView(t.a(this, "layout", "umeng_analyse_feedback_conversation"));
    String str = getIntent().getStringExtra("feedback_id");
    if (str != null)
      this.e = com.feedback.b.c.b(this, str);
    try
    {
      this.f = new c(this, this.e);
      setListAdapter(this.f);
      setSelection(this.f.getCount() - 1);
      this.g = ((TextView)findViewById(t.a(this, "id", "umeng_analyse_feedback_conversation_title")));
      this.h = ((EditText)findViewById(t.a(this, "id", "umeng_analyse_editTxtFb")));
      this.i = ((Button)findViewById(t.a(this, "id", "umeng_analyse_btnSendFb")));
      this.i.setOnClickListener(new a(this));
      this.h.requestFocus();
      registerForContextMenu(getListView());
      a();
      if (this.e.b != e.d)
      {
        this.h.setEnabled(false);
        this.i.setEnabled(false);
      }
      return;
    }
    catch (Exception localException)
    {
      Log.e(c, "In Feedback class,fail to initialize feedback adapter.");
      finish();
    }
  }

  public boolean onKeyDown(int paramInt, KeyEvent paramKeyEvent)
  {
    boolean bool;
    if (paramInt == 4)
      if (a != null)
      {
        com.feedback.b.a.b(a);
        finish();
        bool = true;
      }
    while (true)
    {
      while (true)
      {
        return bool;
        com.feedback.b.a.b(this);
      }
      bool = super.onKeyDown(paramInt, paramKeyEvent);
    }
  }

  protected void onListItemClick(ListView paramListView, View paramView, int paramInt, long paramLong)
  {
    super.onListItemClick(paramListView, paramView, paramInt, paramLong);
    com.feedback.a.a locala = this.e.a(paramInt);
    if (locala.g == com.feedback.a.b.b)
    {
      if (locala.f != com.feedback.a.c.a)
        break label54;
      com.feedback.b.a.a(this, this.e);
      finish();
    }
    while (true)
    {
      return;
      label54: String str = locala.a();
      this.h.setText(str);
      this.h.setEnabled(true);
      this.i.setEnabled(true);
      com.feedback.b.c.a(this, this.e, paramInt);
      this.f.a(this.e);
      this.f.notifyDataSetChanged();
    }
  }

  protected void onStart()
  {
    super.onStart();
    this.j = new b(this, null);
    IntentFilter localIntentFilter = new IntentFilter();
    localIntentFilter.addAction("postFeedbackFinished");
    localIntentFilter.addAction("RetrieveReplyBroadcast");
    registerReceiver(this.j, localIntentFilter);
  }

  protected void onStop()
  {
    super.onStop();
    unregisterReceiver(this.j);
  }
}